/* De Micheli 2017, The Racialized Effects of Social Programs in Brazil */
/* Code for cleaning LAPOP Americas Barometer survey data for Brazil, 2006-2012 */
/* Written by David De Micheli */
/* July 2017 */

use "2008_cleaned.dta", clear

append using 2010_cleaned.dta 2012_cleaned.dta 2014_cleaned.dta, force

gen include = .
replace include = 1 if vote6!=. & bf1!=. & income4!=. & wealth1!=. & educ!=. & age!=. & age2!=. & female!=. & partyid!=. & region!=. & year!=. & race2!=.
replace include = 0 if vote6==. | bf1==. | income4==. | wealth1==. | educ==. | age==. | age2==. | female==. | partyid==. | region==. | year==. | race2==.
keep if include==1
drop include

label define region 1 "North" 2 "Northeast" 3 "Midwest" 4 "Southeast" 5 "South"
label values region region

label define partyid 0 "None" 1 "PT" 2 "PSDB" 3 "PMDB" 4 "Other"
label values partyid partyid

label define race2 0 "White" 1 "Afro-Brazilian"
label values race2 race2

label define bf1 0 "Nonrecipient" 1 "Recipient"
label values bf1 bf1

label define female 0 "Male" 1 "Female"
label values female female

label define vote6 0 "Abstain" 1 "Participate"
label values vote6 vote6

label define vote7 0 "Opposition" 1 "Incumbent"
label values vote7 vote7

label var year ""
label var region ""
label var female "Sex, binary"
label var partyid "Party ID, categorical"
label var race2 "Race, binary"
label var educ "Years of educ., continuous"
label var age "Age, continuous"
label var income4 "Log household income per capita"
label var wealth1 "Household wealth, quintiles"
label var vote6 "Electoral participation, binary"
label var vote7 "Vote choice, binary"

save "lapop-brazil-2008_14.dta", replace
